Skip to content

chore: Add Laravel-style validation rules for game-server environment variables#93

Open
rubentalstra wants to merge 1 commit into
calagopus:mainfrom
rubentalstra:chore/rule-validator-cleanup
Open

chore: Add Laravel-style validation rules for game-server environment variables#93
rubentalstra wants to merge 1 commit into
calagopus:mainfrom
rubentalstra:chore/rule-validator-cleanup

Conversation

@rubentalstra
Copy link
Copy Markdown

This pull request adds comprehensive support for Laravel-style validation rules for environment variables, with a focus on compatibility and extensibility. It introduces a modular structure for validation rule parsing and execution, implements new date validation rules, and provides macros for handling no-op and unsupported rules. The main highlights are:

Core features and structure:

  • Introduced a new modular validation rule system, with themed modules for different rule types and a central dispatch function (parse_validation_rule) to handle rule parsing and instantiation.
  • Added a crate-level documentation comment explaining the purpose, supported Laravel versions, and usage patterns for the validator library.

Date validation rules:

  • Implemented support for Laravel's date validation rules, including date, date_format, after, after_or_equal, before, and before_or_equal, handling both literal dates and field references.

Laravel compatibility and unsupported rules:

  • Added no-op implementations for Laravel rules that do not apply to scalar environment variables (e.g., array rules, input-shaping rules), ensuring they parse and are accepted for compatibility but have no effect.
  • Introduced macros for defining both no-op rules and rules that are explicitly unsupported, providing clear error messages for rules that cannot be honored (e.g., file, image, exists).

@rubentalstra
Copy link
Copy Markdown
Author

PS. test are generated by Claude I did not wrote any test.

I split-up the big rules file in smaller modules and then look at the official documentation from laravel what are new/ nice to have validation rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant